home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-taspri.ads < prev    next >
Text File  |  1994-05-19  |  6KB  |  169 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                S Y S T E M . T A S K _ P R I M I T I V E S               --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.5 $                             --
  10. --                                                                          --
  11. --           Copyright (c) 1991,1992,1993, FSU, All Rights Reserved         --
  12. --                                                                          --
  13. --  GNARL is free software; you can redistribute it and/or modify it  under --
  14. --  terms  of  the  GNU  Library General Public License as published by the --
  15. --  Free Software Foundation; either version 2,  or (at  your  option)  any --
  16. --  later  version.   GNARL is distributed in the hope that it will be use- --
  17. --  ful, but but WITHOUT ANY WARRANTY; without even the implied warranty of --
  18. --  MERCHANTABILITY  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. --  eral Library Public License for more details.  You should have received --
  20. --  a  copy of the GNU Library General Public License along with GNARL; see --
  21. --  file COPYING. If not, write to the Free Software Foundation,  675  Mass --
  22. --  Ave, Cambridge, MA 02139, USA.                                          --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with System.Pthreads;   use System.Pthreads;
  27. with System.POSIX_RTE;  use System.POSIX_RTE;
  28. with System.Task_Clock; use System.Task_Clock;
  29.  
  30. with Unchecked_Conversion;
  31.  
  32. package System.Task_Primitives is
  33.  
  34.    --  Low level Task size and state definition
  35.  
  36.    type Init_State is access procedure (Arg : System.Address);
  37.  
  38.    --  Following should be removed later ???
  39.    type dummy is record
  40.       d : integer;
  41.    end record;
  42.  
  43.    type Pre_Call_State is access dummy;
  44.  
  45.    --  type Pre_Call_State is new System.Address;    ???
  46.  
  47.    type Task_Storage_Size is new Pthreads.size_t;
  48.  
  49.    type Interrupt_ID is new POSIX_RTE.Signal;
  50.  
  51.    type Interrupt_Info is new POSIX_RTE.siginfo_ptr;
  52.  
  53.    type Machine_Exceptions is new POSIX_RTE.Signal;
  54.  
  55.    type Error_Information is new POSIX_RTE.siginfo_ptr;
  56.  
  57.    type Lock is new Pthreads.pthread_mutex_t;
  58.    type Condition_Variable is new Pthreads.pthread_cond_t;
  59.  
  60. --  These definitions has to be private   ???
  61. --   type Lock is private;
  62. --   type Condition_Variable is private;
  63.  
  64.    --  The above types should both be limited.  They are not due to a hack in
  65.    --  ATCB allocation which allocates a block of the correct size and then
  66.    --  assigns an initalizized ATCB to it. This won't work with limited types.
  67.    --  When allocation is done with new, these can become limited once again.
  68.    --  ???
  69.  
  70.    type Task_Control_Block is record
  71.       LL_Entry_Point : Init_State;
  72.       LL_Arg         : System.Address;
  73.       Thread         : Pthreads.pthread_t;
  74.       Stack_Size     : Task_Storage_Size;
  75.       Stack_Limit    : System.Address;
  76.    end record;
  77.  
  78.    type TCB_Ptr is access Task_Control_Block;
  79.  
  80.    --  Task ATCB related and variables.
  81.  
  82.    Test_And_Set_Mutex : Lock;
  83.    --  Use a mutex to simulate test-and-set.  This is ridiculously inefficient;
  84.    --  it is just here so that I can fix the syntax errors without having to
  85.    --  worry about how to get machine code into the system in the absense
  86.    --  of machine code inserts.
  87.  
  88.    function Address_To_TCB_Ptr is new
  89.      Unchecked_Conversion (System.Address, TCB_Ptr);
  90.  
  91.    procedure Initialize_LL_Tasks (T : TCB_Ptr);
  92.  
  93.    function Self return TCB_Ptr;
  94.  
  95.    procedure Initialize_Lock (Prio : System.Priority; L : in out Lock);
  96.  
  97.    procedure Finalize_Lock (L : in out Lock);
  98.  
  99.    procedure Write_Lock (L : in out Lock);
  100.  
  101.    procedure Read_Lock (L : in out Lock);
  102.  
  103.    procedure Unlock (L : in out Lock);
  104.  
  105.    procedure Initialize_Cond (Cond : in out Condition_Variable);
  106.  
  107.    procedure Finalize_Cond (Cond : in out Condition_Variable);
  108.  
  109.    procedure Cond_Wait (Cond : in out Condition_Variable; L : in out Lock);
  110.  
  111.    procedure Cond_Timed_Wait
  112.      (Cond      : in out Condition_Variable;
  113.       L         : in out Lock; Abs_Time : Task_Clock.Stimespec;
  114.       Timed_Out : out Boolean);
  115.  
  116.    procedure Cond_Signal (Cond : in out Condition_Variable);
  117.  
  118.    procedure Cond_Broadcast (Cond : in out Condition_Variable);
  119.  
  120.    procedure Set_Priority (T : TCB_Ptr; Prio : System.Priority);
  121.  
  122.    procedure Set_Own_Priority (Prio : System.Priority);
  123.  
  124.    function Get_Priority (T : TCB_Ptr) return System.Priority;
  125.  
  126.    function Get_Own_Priority return System.Priority;
  127.  
  128.    procedure Create_LL_Task
  129.      (Priority       : System.Priority;
  130.       Stack_Size     :  Task_Storage_Size;
  131.       LL_Entry_Point : Init_State;
  132.       Arg            : System.Address;
  133.       T              : TCB_Ptr);
  134.  
  135.    procedure Exit_LL_Task;
  136.  
  137.    procedure Abort_Task (T : TCB_Ptr);
  138.  
  139.    procedure Test_Abort;
  140.  
  141.    type Abort_Handler_Pointer is access procedure (Context : Pre_Call_State);
  142.  
  143.    procedure Install_Abort_Handler (Handler : Abort_Handler_Pointer);
  144.  
  145.    procedure Install_Error_Handler (Handler : System.Address);
  146.  
  147.    procedure Signal_Task (T : TCB_Ptr; Int_Id : Interrupt_ID);
  148.  
  149.    procedure Wait_For_Signal (Int_Id : Interrupt_ID);
  150.  
  151.    function Reserved_Signal (Int_Id : Interrupt_ID) return Boolean;
  152.  
  153.    procedure LL_Assert (B : Boolean; M : String);
  154.  
  155.    Task_Wrapper_Frame : constant Integer := 72;
  156.    --  This is the size of the frame for the Pthread_Wrapper procedure.
  157.  
  158.    type Proc is access procedure (Addr : System.Address);
  159.  
  160.    procedure Test_And_Set (Flag_Add : System.Address; Result : out Boolean);
  161.    --  Flag_Add is the address of  a variable of type Boolean
  162.  
  163. --  private
  164.  
  165. --  type Lock is new Pthreads.pthread_mutex_t;                     ???
  166. --  type Condition_Variable is new Pthreads.pthread_cond_t;        ???
  167.  
  168. end System.Task_Primitives;
  169.